<?php
//=======================================
//###################################
// Kayako Web Solutions
//
// Source Copyright 2001-2004 Kayako Web Solutions
// Unauthorized reproduction is not allowed
// License Number: $%LICENSE%$
// $Author: rclark $ ($Date: 2007/07/23 21:47:38 $)
// $RCSfile: setup.php,v $ : $Revision: 1.8 $ 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//###################################
//=======================================

if (!defined("INSWIFT")) {
	trigger_error("Unable to process $PHP_SELF", E_USER_ERROR);
}

require_once ("./modules/teamwork/teamwork.php"); // Load the constants
require_once ("./modules/teamwork/functions_misc.php");

/**
* Called when the module is to be installed
*/
function _teamwork_install($action, $page = '') {
	global $_SWIFT, $__LANG;

	/*
DELETE FROM `swcalendarlinks`;
DELETE FROM `swcalendartasks`;
DELETE FROM `swcalendardata`;

DELETE FROM `swcontacts`;
DELETE FROM `swcalendarevents`;
DELETE FROM `swtwdeletelog`;


	*/
	if ($action == "getpages")
	{
		return "1";
	} else if ($action == "buildpage") {
		$_SWIFT["query"]["create"]["calendarlinks"] = "CREATE TABLE ". TABLE_PREFIX ."calendarlinks (
																		linktype SMALLINT(1) UNSIGNED NOT NULL DEFAULT '0',
																		entryid VARCHAR(50) NOT NULL DEFAULT '',
																		typeid INT UNSIGNED NOT NULL DEFAULT '0',
																		guidid INT UNSIGNED NOT NULL DEFAULT '0',
																		lastupdate INT UNSIGNED NOT NULL DEFAULT '0',
																		lastswiftupdate INT UNSIGNED NOT NULL DEFAULT '0',
																		UNIQUE KEY (linktype, entryid, typeid, guidid),
																		KEY calendarlinks1 (entryid),
																		KEY calendarlinks2 (guidid)
																	);";

		$_SWIFT["query"]["create"]["calendartasks"] = "CREATE TABLE ". TABLE_PREFIX ."calendartasks (
																		calendartaskid INT UNSIGNED NOT NULL AUTO_INCREMENT,
																		ownerstaffid INT UNSIGNED NOT NULL DEFAULT '0',
																		staffid INT UNSIGNED NOT NULL DEFAULT '0',
																		dateline INT UNSIGNED NOT NULL DEFAULT '0',
																		duedate INT UNSIGNED NOT NULL DEFAULT '0',
																		startdate INT UNSIGNED NOT NULL DEFAULT '0',
																		contactid INT UNSIGNED NOT NULL DEFAULT '0',
																		completepercent INT(3) UNSIGNED NOT NULL DEFAULT '0',
																		iscomplete SMALLINT(1) UNSIGNED NOT NULL DEFAULT '0',
																		tasktype ENUM('public', 'private') NOT NULL DEFAULT 'public',
																		subject VARCHAR(255) NOT NULL DEFAULT '',
																		calendarlabelid INT UNSIGNED NOT NULL DEFAULT '0',
																		calendarstatusid INT UNSIGNED NOT NULL DEFAULT '0',
																		calendarpriorityid INT UNSIGNED NOT NULL DEFAULT '0',

																		lastupdate INT UNSIGNED NOT NULL DEFAULT '0',
																		PRIMARY KEY (calendartaskid),
																		KEY calendartasks1 (ownerstaffid, duedate, iscomplete),
																		KEY calendartasks2 (tasktype, staffid)
																	);";

		$_SWIFT["query"]["create"]["calendartaskdata"] = "CREATE TABLE ". TABLE_PREFIX ."calendardata (
																		calendardataid INT UNSIGNED NOT NULL AUTO_INCREMENT,
																		datatype SMALLINT(1) UNSIGNED NOT NULL DEFAULT '0',
																		typeid INT UNSIGNED NOT NULL DEFAULT '0',
																		contents TEXT,
																		PRIMARY KEY (calendardataid),
																		KEY calendardata1 (datatype, typeid)
																	);";

		$_SWIFT["query"]["create"]["calendarstatus"] = "CREATE TABLE ". TABLE_PREFIX ."calendarstatus (
																		calendarstatusid INT UNSIGNED NOT NULL AUTO_INCREMENT,
																		statustype SMALLINT(1) UNSIGNED NOT NULL DEFAULT '0',
																		title VARCHAR(255) NOT NULL DEFAULT '',
																		statuscolorcode VARCHAR(20) NOT NULL DEFAULT '#FFFFFF',
																		displayorder INT UNSIGNED NOT NULL DEFAULT '0',
																		ismaster SMALLINT(1) UNSIGNED NOT NULL DEFAULT '0',
																		PRIMARY KEY (calendarstatusid),
																		KEY calendarstatus1 (statustype)
																	);";

		$_SWIFT["query"]["create"]["calendarpriorities"] = "CREATE TABLE ". TABLE_PREFIX ."calendarpriorities (
																		calendarpriorityid INT UNSIGNED NOT NULL AUTO_INCREMENT,
																		prioritytype SMALLINT(1) UNSIGNED NOT NULL DEFAULT '0',
																		title VARCHAR(255) NOT NULL DEFAULT '',
																		prioritycolorcode VARCHAR(20) NOT NULL DEFAULT '#FFFFFF',
																		displayorder INT UNSIGNED NOT NULL DEFAULT '0',
																		ismaster SMALLINT(1) UNSIGNED NOT NULL DEFAULT '0',
																		PRIMARY KEY (calendarpriorityid),
																		KEY calendarpriorities1 (prioritytype)
																	);";

		$_SWIFT["query"]["create"]["calendarlabels"] = "CREATE TABLE ". TABLE_PREFIX ."calendarlabels (
																		calendarlabelid INT UNSIGNED NOT NULL AUTO_INCREMENT,
																		labeltype SMALLINT(1) UNSIGNED NOT NULL DEFAULT '0',
																		title VARCHAR(255) NOT NULL DEFAULT '',
																		labelcolorcode VARCHAR(20) NOT NULL DEFAULT '#FFFFFF',
																		displayorder INT UNSIGNED NOT NULL DEFAULT '0',
																		ismaster SMALLINT(1) UNSIGNED NOT NULL DEFAULT '0',
																		PRIMARY KEY (calendarlabelid),
																		KEY calendarlabels1 (labeltype)
																	);";

		$_SWIFT["query"]["create"]["calendarcategories"] = "CREATE TABLE ". TABLE_PREFIX ."calendarcategories (
																		calendarcategoryid INT UNSIGNED NOT NULL AUTO_INCREMENT,
																		categorytype SMALLINT(1) UNSIGNED NOT NULL DEFAULT '0',
																		title VARCHAR(255) NOT NULL DEFAULT '',
																		displayorder INT UNSIGNED NOT NULL DEFAULT '0',
																		ismaster SMALLINT(1) UNSIGNED NOT NULL DEFAULT '0',
																		PRIMARY KEY (calendarcategoryid),
																		KEY calendarcategories1 (categorytype)
																	);";

		$_SWIFT["query"]["create"]["contacts"] = "CREATE TABLE ". TABLE_PREFIX ."contacts (
																		contactid INT UNSIGNED NOT NULL AUTO_INCREMENT,
																		contacttype ENUM('public', 'private') NOT NULL DEFAULT 'public',
																		staffid INT UNSIGNED NOT NULL DEFAULT '0',

																		fullname VARCHAR(255) NOT NULL DEFAULT '',
																		jobtitle VARCHAR(255) NOT NULL DEFAULT '',
																		initials VARCHAR(5) NOT NULL DEFAULT '',
																		calendarcategoryid INT UNSIGNED NOT NULL DEFAULT '0',
																		email1address VARCHAR(255) NOT NULL DEFAULT '',
																		email2address VARCHAR(255) NOT NULL DEFAULT '',
																		email3address VARCHAR(255) NOT NULL DEFAULT '',
																		customerid VARCHAR(100) NOT NULL DEFAULT '',
																		mobiletelephonenumber VARCHAR(255) NOT NULL DEFAULT '',
																		cartelephonenumber VARCHAR(255) NOT NULL DEFAULT '',
																		pagernumber VARCHAR(255) NOT NULL DEFAULT '',
																		othertelephonenumber VARCHAR(255) NOT NULL DEFAULT '',
																		imaddress VARCHAR(100) NOT NULL DEFAULT '',

																		companyname VARCHAR(255) NOT NULL DEFAULT '',
																		department VARCHAR(255) NOT NULL DEFAULT '',
																		officelocation VARCHAR(255) NOT NULL DEFAULT '',
																		businessaddress VARCHAR(255) NOT NULL DEFAULT '',
																		businesstelephonenumber VARCHAR(255) NOT NULL DEFAULT '',
																		business2telephonenumber VARCHAR(255) NOT NULL DEFAULT '',
																		businessfaxnumber VARCHAR(255) NOT NULL DEFAULT '',
																		businesshomepage VARCHAR(255) NOT NULL DEFAULT '',

																		homeaddress VARCHAR(255) NOT NULL DEFAULT '',
																		hometelephonenumber VARCHAR(255) NOT NULL DEFAULT '',
																		home2telephonenumber VARCHAR(255) NOT NULL DEFAULT '',
																		homefaxnumber VARCHAR(255) NOT NULL DEFAULT '',
																		birthdaydateline INT UNSIGNED NOT NULL DEFAULT '0',
																		anniversarydateline INT UNSIGNED NOT NULL DEFAULT '0',

																		mailingaddress VARCHAR(255) NOT NULL DEFAULT '',
																		otheraddress VARCHAR(255) NOT NULL DEFAULT '',
																		webpage VARCHAR(255) NOT NULL DEFAULT '',

																		assistantname VARCHAR(255) NOT NULL DEFAULT '',
																		assistanttelephonenumber VARCHAR(255) NOT NULL DEFAULT '',

																		lastupdate INT UNSIGNED NOT NULL DEFAULT '0',
																		PRIMARY KEY (contactid),
																		KEY contacts1 (contacttype, staffid)
																	);";

		$_SWIFT["query"]["create"]["calendarevents"] = "CREATE TABLE ". TABLE_PREFIX ."calendarevents (
																		calendareventid INT UNSIGNED NOT NULL AUTO_INCREMENT,
																		eventtype ENUM('public', 'private') NOT NULL DEFAULT 'public',
																		ownerstaffid INT UNSIGNED NOT NULL DEFAULT '0',
																		staffid INT UNSIGNED NOT NULL DEFAULT '0',
																		isalldayevent SMALLINT(1) UNSIGNED NOT NULL DEFAULT '0',
																		dateline INT UNSIGNED NOT NULL DEFAULT '0',
																		subject VARCHAR(255) NOT NULL DEFAULT '',
																		startdateline INT UNSIGNED NOT NULL DEFAULT '0',
																		duration INT UNSIGNED NOT NULL DEFAULT '0',
																		enddateline INT UNSIGNED NOT NULL DEFAULT '0',
																		activitytype SMALLINT(1) UNSIGNED NOT NULL DEFAULT '0',
																		location VARCHAR(255) NOT NULL DEFAULT '',
																		calendarstatusid INT UNSIGNED NOT NULL DEFAULT '0',
																		calendarlabelid INT UNSIGNED NOT NULL DEFAULT '0',
																		calendarcategoryid INT UNSIGNED NOT NULL DEFAULT '0',

																		lastupdate INT UNSIGNED NOT NULL DEFAULT '0',
																		PRIMARY KEY (calendareventid),
																		KEY calendarevent1 (eventtype, staffid, startdateline)
																	);";

		$_SWIFT["query"]["create"]["twdeletelog"] = "CREATE TABLE ". TABLE_PREFIX ."twdeletelog (
																		twdeletelogid INT UNSIGNED NOT NULL AUTO_INCREMENT,
																		entrytype SMALLINT(1) UNSIGNED NOT NULL DEFAULT '0',
																		entryid VARCHAR(50) NOT NULL DEFAULT '',
																		dateline INT UNSIGNED NOT NULL DEFAULT '0',
																		guidid INT UNSIGNED NOT NULL DEFAULT '0',
																		PRIMARY KEY (twdeletelogid),
																		KEY twdeletelog1 (dateline),
																		KEY twdeletelog2 (guidid)
																	);";

		$_SWIFT["query"]["create"]["syncworksguid"] = "CREATE TABLE ". TABLE_PREFIX ."syncworksguid (
																		guidid INT UNSIGNED NOT NULL AUTO_INCREMENT,
																		swguid VARCHAR(50) NOT NULL DEFAULT '',
																		dateline INT UNSIGNED NOT NULL DEFAULT '0',
																		PRIMARY KEY (guidid),
																		KEY syncworksguid (swguid)
																	);";

		$_SWIFT["query"]["create"]["synclog"] = "CREATE TABLE ". TABLE_PREFIX ."synclog (
																		synclogid INT UNSIGNED NOT NULL AUTO_INCREMENT,
																		synctype SMALLINT(1) UNSIGNED NOT NULL DEFAULT '0',
																		staffid INT UNSIGNED NOT NULL DEFAULT '0',
																		syncstatus SMALLINT(1) UNSIGNED NOT NULL DEFAULT '0',
																		dateline INT UNSIGNED NOT NULL DEFAULT '0',
																		deviceinformation VARCHAR(255) NOT NULL DEFAULT '0',
																		PRIMARY KEY (synclogid)
																	);";

		// Register the module
		$_SWIFT["query"]["insert"]["settings"][0] = "INSERT INTO `". TABLE_PREFIX ."settings`(`section`, `vkey`, `data`) VALUES ('registeredmodules', '". MODULE_TEAMWORK ."', '1')";

		// Insert Status
		$_SWIFT["query"]["insert"]["calendarstatus"][] = "INSERT INTO `". TABLE_PREFIX ."calendarstatus` (`statustype`, `title`, `statuscolorcode`, `displayorder`, `ismaster`) VALUES ('". STATUS_TASK ."', '". "Not Started" ."', '". "#686868" ."', '". "1" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarstatus"][] = "INSERT INTO `". TABLE_PREFIX ."calendarstatus` (`statustype`, `title`, `statuscolorcode`, `displayorder`, `ismaster`) VALUES ('". STATUS_TASK ."', '". "In Progress" ."', '". "#5C83B4" ."', '". "2" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarstatus"][] = "INSERT INTO `". TABLE_PREFIX ."calendarstatus` (`statustype`, `title`, `statuscolorcode`, `displayorder`, `ismaster`) VALUES ('". STATUS_TASK ."', '". "Completed" ."', '". "#000000" ."', '". "3" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarstatus"][] = "INSERT INTO `". TABLE_PREFIX ."calendarstatus` (`statustype`, `title`, `statuscolorcode`, `displayorder`, `ismaster`) VALUES ('". STATUS_TASK ."', '". "Awaiting Info" ."', '". "#A5587C" ."', '". "4" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarstatus"][] = "INSERT INTO `". TABLE_PREFIX ."calendarstatus` (`statustype`, `title`, `statuscolorcode`, `displayorder`, `ismaster`) VALUES ('". STATUS_TASK ."', '". "Deferred" ."', '". "#FF8C5A" ."', '". "5" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarstatus"][] = "INSERT INTO `". TABLE_PREFIX ."calendarstatus` (`statustype`, `title`, `statuscolorcode`, `displayorder`, `ismaster`) VALUES ('". STATUS_TASK ."', '". "Planned" ."', '". "#8BB467" ."', '". "6" ."', '1');";

		$_SWIFT["query"]["insert"]["calendarstatus"][] = "INSERT INTO `". TABLE_PREFIX ."calendarstatus` (`statustype`, `title`, `statuscolorcode`, `displayorder`, `ismaster`) VALUES ('". STATUS_EVENT ."', '". "Planned" ."', '". "#8BB467" ."', '". "1" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarstatus"][] = "INSERT INTO `". TABLE_PREFIX ."calendarstatus` (`statustype`, `title`, `statuscolorcode`, `displayorder`, `ismaster`) VALUES ('". STATUS_EVENT ."', '". "Held" ."', '". "#CF5D60" ."', '". "2" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarstatus"][] = "INSERT INTO `". TABLE_PREFIX ."calendarstatus` (`statustype`, `title`, `statuscolorcode`, `displayorder`, `ismaster`) VALUES ('". STATUS_EVENT ."', '". "Not Held" ."', '". "#5C83B4" ."', '". "3" ."', '1');";

		// Insert Priorities
		$_SWIFT["query"]["insert"]["calendarpriorities"][] = "INSERT INTO `". TABLE_PREFIX ."calendarpriorities` (`prioritytype`, `title`, `prioritycolorcode`, `displayorder`, `ismaster`) VALUES ('". PRIORITY_TASK ."', '". "Low" ."', '". "#747474" ."', '". "1" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarpriorities"][] = "INSERT INTO `". TABLE_PREFIX ."calendarpriorities` (`prioritytype`, `title`, `prioritycolorcode`, `displayorder`, `ismaster`) VALUES ('". PRIORITY_TASK ."', '". "Normal" ."', '". "#000000" ."', '". "2" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarpriorities"][] = "INSERT INTO `". TABLE_PREFIX ."calendarpriorities` (`prioritytype`, `title`, `prioritycolorcode`, `displayorder`, `ismaster`) VALUES ('". PRIORITY_TASK ."', '". "High" ."', '". "#CF5D60" ."', '". "3" ."', '1');";

		// Insert Labels
		$_SWIFT["query"]["insert"]["calendarlabels"][] = "INSERT INTO `". TABLE_PREFIX ."calendarlabels` (`labeltype`, `title`, `labelcolorcode`, `displayorder`, `ismaster`) VALUES ('". LABEL_TASK ."', '". "Important" ."', '". "#CF5D60" ."', '". "1" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarlabels"][] = "INSERT INTO `". TABLE_PREFIX ."calendarlabels` (`labeltype`, `title`, `labelcolorcode`, `displayorder`, `ismaster`) VALUES ('". LABEL_TASK ."', '". "Business" ."', '". "#5C83B4" ."', '". "2" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarlabels"][] = "INSERT INTO `". TABLE_PREFIX ."calendarlabels` (`labeltype`, `title`, `labelcolorcode`, `displayorder`, `ismaster`) VALUES ('". LABEL_TASK ."', '". "Personal" ."', '". "#8BB467" ."', '". "3" ."', '1');";

		$_SWIFT["query"]["insert"]["calendarlabels"][] = "INSERT INTO `". TABLE_PREFIX ."calendarlabels` (`labeltype`, `title`, `labelcolorcode`, `displayorder`, `ismaster`) VALUES ('". LABEL_EVENT ."', '". "Important" ."', '". "#CF5D60" ."', '". "1" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarlabels"][] = "INSERT INTO `". TABLE_PREFIX ."calendarlabels` (`labeltype`, `title`, `labelcolorcode`, `displayorder`, `ismaster`) VALUES ('". LABEL_EVENT ."', '". "Business" ."', '". "#5C83B4" ."', '". "2" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarlabels"][] = "INSERT INTO `". TABLE_PREFIX ."calendarlabels` (`labeltype`, `title`, `labelcolorcode`, `displayorder`, `ismaster`) VALUES ('". LABEL_EVENT ."', '". "Personal" ."', '". "#8BB467" ."', '". "3" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarlabels"][] = "INSERT INTO `". TABLE_PREFIX ."calendarlabels` (`labeltype`, `title`, `labelcolorcode`, `displayorder`, `ismaster`) VALUES ('". LABEL_EVENT ."', '". "Vacation" ."', '". "#959595" ."', '". "4" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarlabels"][] = "INSERT INTO `". TABLE_PREFIX ."calendarlabels` (`labeltype`, `title`, `labelcolorcode`, `displayorder`, `ismaster`) VALUES ('". LABEL_EVENT ."', '". "Must Attend" ."', '". "#FF8C5A" ."', '". "5" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarlabels"][] = "INSERT INTO `". TABLE_PREFIX ."calendarlabels` (`labeltype`, `title`, `labelcolorcode`, `displayorder`, `ismaster`) VALUES ('". LABEL_EVENT ."', '". "Travel Required" ."', '". "#2C60A1" ."', '". "6" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarlabels"][] = "INSERT INTO `". TABLE_PREFIX ."calendarlabels` (`labeltype`, `title`, `labelcolorcode`, `displayorder`, `ismaster`) VALUES ('". LABEL_EVENT ."', '". "Needs Preparation" ."', '". "#FFC160" ."', '". "7" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarlabels"][] = "INSERT INTO `". TABLE_PREFIX ."calendarlabels` (`labeltype`, `title`, `labelcolorcode`, `displayorder`, `ismaster`) VALUES ('". LABEL_EVENT ."', '". "Birthday" ."', '". "#A5587C" ."', '". "8" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarlabels"][] = "INSERT INTO `". TABLE_PREFIX ."calendarlabels` (`labeltype`, `title`, `labelcolorcode`, `displayorder`, `ismaster`) VALUES ('". LABEL_EVENT ."', '". "Anniversary" ."', '". "#8BB467" ."', '". "9" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarlabels"][] = "INSERT INTO `". TABLE_PREFIX ."calendarlabels` (`labeltype`, `title`, `labelcolorcode`, `displayorder`, `ismaster`) VALUES ('". LABEL_EVENT ."', '". "Phone Call" ."', '". "#FFC160" ."', '". "10" ."', '1');";

		// Insert Categories
		$_SWIFT["query"]["insert"]["calendarcategories"][] = "INSERT INTO `". TABLE_PREFIX ."calendarcategories` (`categorytype`, `title`, `displayorder`, `ismaster`) VALUES ('". CATEGORY_EVENT ."', '". "Business" ."', '"."1" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarcategories"][] = "INSERT INTO `". TABLE_PREFIX ."calendarcategories` (`categorytype`, `title`, `displayorder`, `ismaster`) VALUES ('". CATEGORY_EVENT ."', '". "Personal" ."', '"."2" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarcategories"][] = "INSERT INTO `". TABLE_PREFIX ."calendarcategories` (`categorytype`, `title`, `displayorder`, `ismaster`) VALUES ('". CATEGORY_EVENT ."', '". "Objectives" ."', '"."3" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarcategories"][] = "INSERT INTO `". TABLE_PREFIX ."calendarcategories` (`categorytype`, `title`, `displayorder`, `ismaster`) VALUES ('". CATEGORY_EVENT ."', '". "Holiday" ."', '"."4" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarcategories"][] = "INSERT INTO `". TABLE_PREFIX ."calendarcategories` (`categorytype`, `title`, `displayorder`, `ismaster`) VALUES ('". CATEGORY_EVENT ."', '". "Ideas" ."', '"."5" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarcategories"][] = "INSERT INTO `". TABLE_PREFIX ."calendarcategories` (`categorytype`, `title`, `displayorder`, `ismaster`) VALUES ('". CATEGORY_EVENT ."', '". "International" ."', '"."6" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarcategories"][] = "INSERT INTO `". TABLE_PREFIX ."calendarcategories` (`categorytype`, `title`, `displayorder`, `ismaster`) VALUES ('". CATEGORY_EVENT ."', '". "Phone Calls" ."', '"."7" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarcategories"][] = "INSERT INTO `". TABLE_PREFIX ."calendarcategories` (`categorytype`, `title`, `displayorder`, `ismaster`) VALUES ('". CATEGORY_EVENT ."', '". "Time & Expenses" ."', '"."8" ."', '1');";

		$_SWIFT["query"]["insert"]["calendarcategories"][] = "INSERT INTO `". TABLE_PREFIX ."calendarcategories` (`categorytype`, `title`, `displayorder`, `ismaster`) VALUES ('". CATEGORY_CONTACT ."', '". "Business" ."', '"."1" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarcategories"][] = "INSERT INTO `". TABLE_PREFIX ."calendarcategories` (`categorytype`, `title`, `displayorder`, `ismaster`) VALUES ('". CATEGORY_CONTACT ."', '". "Competition" ."', '"."2" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarcategories"][] = "INSERT INTO `". TABLE_PREFIX ."calendarcategories` (`categorytype`, `title`, `displayorder`, `ismaster`) VALUES ('". CATEGORY_CONTACT ."', '". "Personal" ."', '"."3" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarcategories"][] = "INSERT INTO `". TABLE_PREFIX ."calendarcategories` (`categorytype`, `title`, `displayorder`, `ismaster`) VALUES ('". CATEGORY_CONTACT ."', '". "VIP" ."', '"."4" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarcategories"][] = "INSERT INTO `". TABLE_PREFIX ."calendarcategories` (`categorytype`, `title`, `displayorder`, `ismaster`) VALUES ('". CATEGORY_CONTACT ."', '". "Favorites" ."', '"."5" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarcategories"][] = "INSERT INTO `". TABLE_PREFIX ."calendarcategories` (`categorytype`, `title`, `displayorder`, `ismaster`) VALUES ('". CATEGORY_CONTACT ."', '". "Hot Contacts" ."', '"."6" ."', '1');";
		$_SWIFT["query"]["insert"]["calendarcategories"][] = "INSERT INTO `". TABLE_PREFIX ."calendarcategories` (`categorytype`, `title`, `displayorder`, `ismaster`) VALUES ('". CATEGORY_CONTACT ."', '". "Key Customer" ."', '"."7" ."', '1');";

		execAllQueries();

		// ======= CACHES =======
		rebuildCalendarStatusCache();

		rebuildCalendarPriorityCache();

		rebuildCalendarLabelCache();

		rebuildCalendarCategoryCache();
	}
}

/**
* Uninstall Routine
*/
function _teamwork_uninstall()
{
	global $_SWIFT;

	$_SWIFT["query"]["drop"]["calendarlinks"] = "DROP TABLE `". TABLE_PREFIX ."calendarlinks`;";

	$_SWIFT["query"]["drop"]["calendarstatus"] = "DROP TABLE `". TABLE_PREFIX ."calendarstatus`;";

	$_SWIFT["query"]["drop"]["calendarpriorities"] = "DROP TABLE `". TABLE_PREFIX ."calendarpriorities`;";

	$_SWIFT["query"]["drop"]["calendarlabels"] = "DROP TABLE `". TABLE_PREFIX ."calendarlabels`;";

	$_SWIFT["query"]["drop"]["calendarcategories"] = "DROP TABLE `". TABLE_PREFIX ."calendarcategories`;";

	$_SWIFT["query"]["drop"]["calendartasks"] = "DROP TABLE `". TABLE_PREFIX ."calendartasks`;";

	$_SWIFT["query"]["drop"]["calendarevents"] = "DROP TABLE `". TABLE_PREFIX ."calendarevents`;";

	$_SWIFT["query"]["drop"]["calendardata"] = "DROP TABLE `". TABLE_PREFIX ."calendardata`;";

	$_SWIFT["query"]["drop"]["contacts"] = "DROP TABLE `". TABLE_PREFIX ."contacts`;";

	$_SWIFT["query"]["drop"]["synclog"] = "DROP TABLE `". TABLE_PREFIX ."synclog`;";

	$_SWIFT["query"]["drop"]["twdeletelog"] = "DROP TABLE `". TABLE_PREFIX ."twdeletelog`;";

	$_SWIFT["query"]["drop"]["syncworksguid"] = "DROP TABLE `". TABLE_PREFIX ."syncworksguid`;";

	$_SWIFT["query"]["delete"]["settings"][0] = "DELETE FROM `". TABLE_PREFIX ."settings` WHERE `section` = 'registeredmodules' AND `vkey` = '". MODULE_TEAMWORK ."';";
}
?>